package com.yangmao.dao;

import com.yangmao.entity.Admin;
import com.yangmao.entity.Student;
import com.yangmao.entity.WorkPeople;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author ‘洋毛’
 * @version 1.0
 * @description: TODO
 * @date 2022/1/5 22:09
 */
public interface WorkPeopleDao {
    @Select("select * from work_people")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "position",column = "position"),
            @Result(property = "type",column = "type"),
            @Result(property = "job",column = "job"),
            @Result(property = "create_time",column = "create_time"),
            @Result(property = "update_time",column = "update_time"),
            @Result(property = "student",column = "id",javaType = com.yangmao.entity.Student.class,one = @One(select = "com.yangmao.dao.StudentDao.getStudentById"))
    })
    List<WorkPeople> getAllWorkPeople();

    @Select("select * from work_people where id= #{id}")
    WorkPeople getWorkPeopleById(String id);

    @Update("update work_people set position=#{position},type=#{type},job=#{job},update_time=#{update_time} where id = #{id}")
    void updateWorkPeople(WorkPeople workPeople);

    @Delete("delete from work_people where id=#{id}")
    void deleteWorkPeopleById(String id);

    @Insert("insert into work_people values(#{id},#{position},#{type},#{job},#{create_time},#{update_time})")
    void addWorkPeople(WorkPeople workPeople);

    List<WorkPeople> getWorkPeopleByIdAndPosition(@Param("id")String id,@Param("position") String position);
}
